function customSort(arr, target) {
  let index = arr.findIndex((item) => item === target)
  // console.log(index)
  if(index!==-1) {
    return index
  }

  if(target<arr[0]) {
    return 0
  }
  if(target>arr[arr.length-1]) {
    return arr.length
  }
  let i = 0
  while(arr[i]<target) {
    i++
  }
  return i
  // for (let i = 0; i < arr.length-1; i++) {
  //   if(arr[i]<target && arr[i+1]>target) {
  //     result = i+1
  //   }
  // }
  // return result
}
let nums = [1,3,5,6]
let target = 4
let result = customSort(nums, target)
console.log(result)


function customArr(arr, target) {
  let result= []
  for (let i = 0; i < arr.length; i++) {
    let value = target - arr[i]
    if(value === 0) {
      result.push([target])
    } else if(arr.includes(value)) {
      result.push([value, arr[i]])
    }else {
      for(let j= 0;j<arr.length;j++) {

        if(value%arr[j] === 0) {
          let arrItem = [arr[i]]
          let times = value/arr[j]
          for(let x = 0;x<times;x++) {
            arrItem.push(arr[j])
          }
          result.push(arrItem)
        }
      }
    }
  }
  let temArr = result.map(item => item.sort((a,b) => a - b)).map(item => item.join(','))
  let resultArr = [...new Set(temArr)].map(item => item.split(','))
  return resultArr
}
console.log(customArr([2,3,5], 8))




let a = 123
let b = a

b = 123
a = 234
b //123



let obj = {
  name: '刘德华'
}
//存的是个指针


let obj1 = obj
// 指针赋给obj1

obj.name = '张学友'

obj1.name //刘德华 ==>张学友
